<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8" />
        <link rel="stylesheet" href="styles/style.css">
        <link rel="stylesheet" href="styles/theme/atom-one-dark.css">
        <title>例子37-ES6/7常用语法介绍</title>
    </head>

    <body>
        <pre>
            <code>
                // 例子37

                let colors = ['red', 'yellow', 'blue', 'green'];
                for(color of colors) {
                    console.log(color); // 前后分别输出"red" "yellow" "blue" "green"
                }

                colors.forEach((color, index) => {
                    console.log([index, color]); // 前后分别输出[0, "red"] [1, "yellow"] [2, "blue"] [3, "green"]
                })

                for([index, color] of colors.entries()) {
                    console.log([index, color]); // 前后分别输出[0, "red"] [1, "yellow"] [2, "blue"] [3, "green"]
                }
            </code>
        </pre>
        <script src="scripts/libs/highlight.pack.js"></script>
        <script src="scripts/37.js"></script>
        <script>
            hljs.initHighlightingOnLoad();
        </script>
    </body>

</html>